package com.seadragon.app.ksr.dao.jpa;

import java.util.List;

import javax.persistence.Query;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.seadragon.app.ksr.dao.CountyDao;
import com.seadragon.app.ksr.model.tiger.County;

@SuppressWarnings("unchecked")
@Repository("countyDao")
public class CountyDaoJpaImpl extends AbstractJpaDao implements CountyDao {
	private static Logger logger = LoggerFactory.getLogger(CountyDaoJpaImpl.class);

	@Override
	public List<County> findAdjacentCounties(String countyName, String statefp) {
		logger.info("Entering ... ");
		Query q = entityManager.createNamedQuery("findAdjacentCounties").setParameter("countyName", countyName).setParameter("statefp", statefp);
		q.setHint("org.hibernate.readOnly",true);
		logger.info("Leaving ...");
		return (List<County>)q.getResultList();
	}
}
